#pragma once
#include <iostream>
#include <vector>

template<typename T>
class CVector : public std::vector<T> {
public:
	using std::vector<T>::vector;// Inherit all constructors from the base class

	CVector& operator<<(const T& value) {
		this->push_back(value);
		return *this;
	}

	void remove(const T& t) {
		this->erase(std::remove(this->begin(), this->end(), t), this->end());
	}

	void removeFirst() {// efficiency: O(n), requires moving remaining elements => using std::list instead
		if (!this->empty())
			this->erase(this->begin());
	}

	void removeLast() {// efficiency: O(1), no need to move elements
		if (!this->empty())
			this->pop_back();
	}
	friend std::ostream& operator<<(std::ostream &os, const CVector &vec) {
		os << "Size: " << vec.size() << ", Elements: [";
		for (int i = 0; i < vec.size(); ++i) {
			os << vec[i];
			if (i != vec.size() - 1) os << ", ";
		}
		os << "]";
		return os;
	}
	
	bool contains(const T& element) const {
		return std::find(this->begin(), this->end(), element) != this->end();
	}
};